#-*- codig:utf-8 -*-
import urllib.request
import json
from city import city

while True:
    cityname=input('请输入你要查询的城市:(按q退出)\n)
    if cityname='q' or cityname='Q':
        print('退出！')
        break
    else:
        citycode=city.get(cityname)
        if citycode:
            try:
                url='http:www.weather.com.cn/data/cityinfo/%s.html'%citycode
                resp=urllib.request.urlopen(url)
                content=resp.read().decode('utf-8')
                data=josn.loads(content)
                print(data)
            except:
                print('查询失败')
        else:
            print('没有找到该城市'）
                
    
    